/*
 * GPUC
 * 
 * Copyright © 2008 Attila T. Áfra <attila.afra@gmail.com>
 * 
 * This program is free software: you can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with this program. If
 * not, see <http://www.gnu.org/licenses/>.
 */

const char GPUC_fragmentShaderSourceCodePrologue[] =
    "#extension GL_ARB_texture_rectangle : enable\n"
    "\n"
    "#define param uniform\n"
    "\n"
    "typedef sampler2DRect stream;\n"
    "typedef vec2 float2;\n"
    "typedef vec3 float3;\n"
    "typedef vec4 float4;\n"
    "typedef ivec2 int2;\n"
    "typedef ivec3 int3;\n"
    "typedef ivec4 int4;\n"
    "typedef bvec2 bool2;\n"
    "typedef bvec3 bool3;\n"
    "typedef bvec4 bool4;\n"
    "typedef mat2 float2x2;\n"
    "typedef mat3 float3x3;\n"
    "typedef mat4 float4x4;\n" 
    "\n"
    "const float2 OutCoordFloat = floor(gl_FragCoord.xy);\n"
    "const int2 OutCoord = int2(OutCoordFloat);\n"
    "\n"
    "float streamIn1(stream input) { return texture2DRect(input, gl_FragCoord.xy).x; }\n"
    "float2 streamIn2(stream input) { return texture2DRect(input, gl_FragCoord.xy).zw; }\n"
    "float3 streamIn3(stream input) { return texture2DRect(input, gl_FragCoord.xy).xyz; }\n"
    "float4 streamIn4(stream input) { return texture2DRect(input, gl_FragCoord.xy); }\n"
    "\n"
    "float streamIn1(stream input, int2 coord) { return texture2DRect(input, float2(coord)).x; }\n"
    "float2 streamIn2(stream input, int2 coord) { return texture2DRect(input, float2(coord)).zw; }\n"
    "float3 streamIn3(stream input, int2 coord) { return texture2DRect(input, float2(coord)).xyz; }\n"
    "float4 streamIn4(stream input, int2 coord) { return texture2DRect(input, float2(coord)); }\n"
    "\n"
    "float streamIn1(stream input, float2 coord) { return texture2DRect(input, coord).x; }\n"
    "float2 streamIn2(stream input, float2 coord) { return texture2DRect(input, coord).zw; }\n"
    "float3 streamIn3(stream input, float2 coord) { return texture2DRect(input, coord).xyz; }\n"
    "float4 streamIn4(stream input, float2 coord) { return texture2DRect(input, coord); }\n"
    "\n"
    "float streamIn1Offset(stream input, int2 offset)"
    " { return texture2DRect(input, gl_FragCoord.xy + float2(offset)).x; }\n"
    "float2 streamIn2Offset(stream input, int2 offset)"
    " { return texture2DRect(input, gl_FragCoord.xy + float2(offset)).zw; }\n"
    "float3 streamIn3Offset(stream input, int2 offset)"
    " { return texture2DRect(input, gl_FragCoord.xy + float2(offset)).xyz; }\n"
    "float4 streamIn4Offset(stream input, int2 offset)"
    " { return texture2DRect(input, gl_FragCoord.xy + float2(offset)); }\n"
    "\n"
    "float streamIn1Offset(stream input, float2 offset)"
    " { return texture2DRect(input, OutCoordFloat + offset).x; }\n"
    "float2 streamIn2Offset(stream input, float2 offset)"
    " { return texture2DRect(input, OutCoordFloat + offset).zw; }\n"
    "float3 streamIn3Offset(stream input, float2 offset)"
    " { return texture2DRect(input, OutCoordFloat + offset).xyz; }\n"
    "float4 streamIn4Offset(stream input, float2 offset)"
    " { return texture2DRect(input, OutCoordFloat + offset); }\n"
    "\n"
    "void streamOut(float value) { gl_FragColor.x = value; }\n"
    "void streamOut(float3 value) { gl_FragColor.xyz = value; }\n"
    "void streamOut(float4 value) { gl_FragColor = value; }\n"
    "\n"
    "void streamOut(int outputIndex, float value) { gl_FragData[outputIndex].x = value; }\n"
    "void streamOut(int outputIndex, float3 value) { gl_FragData[outputIndex].xyz = value; }\n"
    "void streamOut(int outputIndex, float4 value) { gl_FragData[outputIndex] = value; }\n"
    "\n\n";

/*------------------------------------------------------------------------------------------------*/

const char GPUC_vertexShaderSourceCode[] =
    "void main()\n"
    "{\n"
    "    gl_Position = gl_Vertex;\n"
    "}\n";

/*------------------------------------------------------------------------------------------------*/
